import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { JVxeTypes, JVxeColumn } from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [


  //  {
  //   title: '单据类型id',
  //   align:"center",
  //   dataIndex: 'billTypeId'
  //  },
  {
    title: '单据类型',
    align: "center",
    sorter: true,
    dataIndex: 'billTypeName'
  },
  {
    title: '采购收货编号',
    align: "center",
    sorter: true,
    dataIndex: 'purchaseReceiveCode'
  },
  //  {
  //   title: '供应商id',
  //   align:"center",
  //   dataIndex: 'supplierId'
  //  },
  {
    title: '供应商',
    align: "center",
    dataIndex: 'supplierName'
  },
  //  {
  //   title: '币种id',
  //   align:"center",
  //   dataIndex: 'currencyId'
  //  },
  {
    title: '币种',
    align: "center",
    dataIndex: 'currencyName'
  },
  //  {
  //   title: '来源id',
  //   align:"center",
  //   dataIndex: 'srcBillId'
  //  },
  {
    title: '来源类型',
    align: "center",
    dataIndex: 'srcBillType'
  },
  {
    title: '来源单据编号',
    align: "center",
    sorter: true,
    dataIndex: 'srcBillCode'
  },
  //  {
  //   title: '收货部门id',
  //   align:"center",
  //   dataIndex: 'receivingDepartmentId'
  //  },
  {
    title: '退货部门',
    align: "center",
    sorter: true,
    dataIndex: 'receivingDepartmentName'
  },
   {
    title: '供应商',
    align:"center",
    dataIndex: 'supplierName'
   },
  {
    title: '库管员',
    align: "center",
    sorter: true,
    dataIndex: 'warehouseKeeperName'
  },
  {
    title: '采购日期',
    align: "center",
    sorter: true,
    dataIndex: 'arrivalDate',
    customRender: ({ text }) => {
      return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
    },
  },
  {
    title: '收货原则',
    align: "center",
    dataIndex: 'receivingPrinciple'
  },
  //  {
  //   title: '收货原则id',
  //   align:"center",
  //   dataIndex: 'receiptPrincipleId'
  //  },
  {
    title: '业务交期',
    align: "center",
    sorter: true,
    dataIndex: 'businessDeliveryTime',
    customRender: ({ text }) => {
      return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
    },
  },
  {
    title: '税组合',
    align: "center",
    dataIndex: 'taxPortfolio'
  },
  //  {
  //   title: '税组合id',
  //   align:"center",
  //   dataIndex: 'taxPortfolioId'
  //  },
  {
    title: '税率',
    align: "center",
    dataIndex: 'taxRate'
  },
  {
    title: '是否含税',
    align: "center",
    sorter: true,
    dataIndex: 'whetherTax'
  },
  {
    title: '第三方编码',
    align: "center",
    dataIndex: 'thirdPartyCode',
    ifShow: false
  },
  {
    title: '单据状态',
    align: "center",
    dataIndex: 'billStatus',
    ifShow: false,
    customRender: ({ text }) => {
      return text==1?'已审核':text==0?"开立":text==-1?'作废':''
    },
  },
  {
    title: '备注',
    align: "center",
    dataIndex: 'remark'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "单据类型",
    field: "billTypeName",
    component: 'Input',
    colProps: { span: 6 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  // {
  //   label: '单据状态',
  //   field: 'billStatus',
  //   component: 'Input',
  // },
  {
    label: '单据类型id',
    field: 'billTypeId',
    component: 'Input',
    show: false
  },
  {
    label: '单据类型',
    field: 'billTypeName',
    component: 'Input',
    slot: 'billTypeSlot'

  },
  // {
  //   label: '采购收货编号',
  //   field: 'purchaseReceiveCode',
  //   component: 'Input',
  // },
  {
    label: '供应商id',
    field: 'supplierId',
    component: 'Input',
    show: false
  },
  {
    label: '供应商',
    field: 'supplierName',
    component: 'Input',
    slot: 'supplierSlot'
  },
  {
    label: '币种id',
    field: 'currencyId',
    component: 'Input',
    show: false
  },
  {
    label: '币种',
    field: 'currencyName',
    component: 'Input',
    slot: 'currencySlot'
  },
  {
    label: '来源id',
    field: 'srcBillId',
    component: 'Input',
    show: false
  },
  {
    label: '来源类型',
    field: 'srcBillType',
    component: 'Input',
  },
  {
    label: '来源单据编号',
    field: 'srcBillCode',
    component: 'Input',
  },
  {
    label: '收货部门id',
    field: 'receivingDepartmentId',
    component: 'Input',
    show: false
  },
  {
    label: '退货部门',
    field: 'receivingDepartmentId',
    component: 'JSelectDept',
    componentProps: ({}) => {
      return {
        multiple: false,
        showButton: false,
        checkable: false
      }
    },
  },
  {
    label: '库管员id',
    field: 'warehouseKeeperId',
    component: 'Input',
    show: false
  },
  {
    label: '库管员',
    field: 'warehouseKeeperId',
    component: 'JSelectUser',
    componentProps: ({ }) => {
      return {
        isRadioSelection: true,
        showButton: false
      }
    },

  },
  {
    label: '入库日期',
    field: 'arrivalDate',
    component: 'DatePicker',
  },
  {
    label: '收货原则',
    field: 'receivingPrinciple',
    component: 'Input',
    slot: 'receivingPrincipleSlot'
  },
  {
    label: '收货原则id',
    field: 'receiptPrincipleId',
    component: 'Input',
    show: false
  },
  {
    label: '业务交期',
    field: 'businessDeliveryTime',
    component: 'DatePicker',
  },
  {
    label: '番号',
    field: 'designation',
    component: 'Input',
  },
  {
    label: '项目号id',
    field: 'projectId',
    component: 'Input',
    show: false
  },
  {
    label: '项目号编码',
    field: 'projectCode',
    component: 'Input',
  },
  {
    label: '需求分类',
    field: 'requirementsType',
    component: 'Input',
  },
  {
    label: '税组合',
    field: 'taxPortfolio',
    component: 'Input',
    slot: 'taxPortfolioSlot',
    dynamicRules: ({ }) => {
      return [
        { required: true, message: '请选择税组合!' },
      ];
    },
  },
  {
    label: '税组合id',
    field: 'taxPortfolioId',
    component: 'Input',
    show: false
  },
  {
    label: '税率',
    field: 'taxRate',
    component: 'InputNumber',
  },
  {
    label: '是否含税',
    field: 'whetherTax',
    component: 'Select',
    defaultValue: 0,
    componentProps: {
      options: [{ label: '否', value: 0 }, { label: '是', value: 1 }]
    },
  },
  {
    label: '第三方编码',
    field: 'thirdPartyCode',
    component: 'Input',
    ifShow: false
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
  },

  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];
//子表单数据
//子表表格配置
export const busPurchaseReceiveItemColumns: JVxeColumn[] = [

  // {
  //   title: '组织id',
  //   key: 'organizationId',
  //   type: JVxeTypes.input,
  //   width:"200px",
  //   placeholder: '请输入${title}',
  //   defaultValue:'',
  // },
  // {
  //   title: '租户id',
  //   key: 'tenantId',
  //   type: JVxeTypes.inputNumber,
  //   width:"200px",
  //   placeholder: '请输入${title}',
  //   defaultValue:'',
  // },
  // {
  //   title: '删除状态 0正常 1已删除',
  //   key: 'delFlag',
  //   type: JVxeTypes.input,
  //   width:"200px",
  //   placeholder: '请输入${title}',
  //   defaultValue:'',
  // },
  // {
  //   title: '单据状态',
  //   key: 'billStatus',
  //   type: JVxeTypes.input,
  //   width:"200px",
  //   placeholder: '请输入${title}',
  //   defaultValue:'',
  // },

  {
    title: '采购单Id',
    key: 'purchaseReceiveId',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '料品ID',
    key: 'materialId',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '料品编号',
    key: 'materialCode',
    type: JVxeTypes.slot,
    width: "200px",
    placeholder: '请输入${title}',
    slotName: 'action',
    validateRules: [
      {
        required: true,
        message: '请选择料品编号'
      }
    ]
  },
  {
    title: '料品',
    key: 'materialName',
    type: JVxeTypes.normal,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '规格',
    key: 'specifications',
    type: JVxeTypes.normal,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: ''
  },
  {
    title: '单位id',
    key: 'unitId',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '单位',
    key: 'unitName',
    width: "200px",
    type: JVxeTypes.normal,
  },
  {
    title: '来源单据ID',
    key: 'srcBillId',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '来源单据编号',
    key: 'srcBillCode',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  // {
  //   title: '存储地点',
  //   key: 'storageLocation',
  //   type: JVxeTypes.slot,
  //   width:"200px",
  //   placeholder: '请输入${title}',
  //   defaultValue:'',
  //   slotName:'warehouse'
  // },
  // {
  //   title: '存储地点id',
  //   key: 'storageLocationId',
  //   type: JVxeTypes.hidden,
  //   width:"200px",
  //   placeholder: '请输入${title}',
  //   defaultValue:'',
  // },
  // {
  //   title: '实收数量',
  //   key: 'actualQuantityReceived',
  //   type: JVxeTypes.inputNumber,
  //   width:"200px",
  //   placeholder: '请输入${title}',
  //   defaultValue:'',
  // },
  {
    title: '采购数量',
    key: 'purchaseQuantity',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
    validateRules: [
      {
        required: true,
        message: '请输入采购数量'
      }
    ]
  },
  {
    title: '采购单价',
    key: 'purchasePrice',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
    validateRules: [
      {
        required: true,
        message: '请输入采购单价'
      }
    ]
  },
  {
    title: '价税合计',
    key: 'totalValueTax',
    type: JVxeTypes.inputNumber,
    width: "200px",
    disabled: true,
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '未税金额',
    key: 'amountNotTaxed',
    type: JVxeTypes.inputNumber,
    width: "200px",
    disabled: true,
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '税额',
    key: 'tax',
    type: JVxeTypes.inputNumber,
    width: "200px",
    disabled: true,
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '番号',
    key: 'designation',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '项目号id',
    key: 'projectId',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '项目号编码',
    key: 'projectCode',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '需求分类',
    key: 'requirementsType',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '第三方编码',
    key: 'thirdPartyCode',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '备注',
    key: 'remark',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
]


/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}